package com.sengled.cloud.biz.union.mgt.common;

public class PageUtil {

	public int getRowCount() {
		return rowCount;
	}


	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}


	public int getPageSize() {
		return pageSize;
	}


	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}


	public int getPageCount() {
		return pageCount;
	}


	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}


	public int getPage() {
		return page;
	}


	public void setPage(int page) {
		this.page = page;
	}


	public int getStartIndex() {
		return startIndex;
	}


	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}


	public int getEndIndex() {
		return endIndex;
	}


	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}


	public int rowCount = 0; // 总数
	public int pageSize = 10; // 每页显示数
	public int pageCount = 0; // 总页数
	public int page = 1; // 当前页数
	public int startIndex = 0;
	public int endIndex = 0;
	public int start = 0;
	public PageUtil(){

	}
	

	public PageUtil(int page, int pageSize, int rowCount) {
		this.page = page;
		this.pageSize = pageSize;
		this.rowCount = rowCount;

		if (page < 1)
			page = 1;
		pageCount = (rowCount + pageSize - 1) / pageSize;
		if (page != 1 && page > pageCount)
			page = pageCount;
		    //totalPages = totalRecords%q.getPageSize()==0?totalRecords/q.getPageSize():totalRecords/totalRecords+1;
		startIndex = (page - 1) * pageSize + 1;
		if(startIndex>rowCount){
			startIndex = rowCount;
		}
		endIndex = page * pageSize;
		if( endIndex> rowCount) {
			endIndex = rowCount;
        }
		this.page = page;
		this.start = this.startIndex - 1;
	}
	

}
